<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div>123</div>
    <a href="http://www.baidu.com">百度</a>
    <form action="http://www.baidu.com">
        <input type="submit" value="提交" name="sub">
    </form>
    <script>
        var div = document.querySelector('div');
        function fn(e){
            console.log(e.type);
        }
        div.addEventListener('click',fn);
        div.addEventListener('mouseover',fn);
        div.addEventListener('mouseout',fn);

        //阻止默认行为
        var a = document.querySelector('a');
        a.addEventListener('click',function(e){
            //  dom 标准写法  阻止默认行为
            e.preventDefault();
        })
        //传统阻止默认方式
        a.onclick = function(e){
            //普通浏览器
            // e.preventDefault();
            //低版本浏览器
            // e.returnValue;
            //return false 也能阻止默认行为
        }
    </script>
</body>
</html>